#include <map>
#include <vector>
#include <queue>
using namespace std;
#include <boost/shared_ptr.hpp>
#include <wx/wx.h>
#include <wx/dir.h>
#include <wx/filename.h>
#include <wx/listctrl.h>
#include "wx/dnd.h"
#include "wx/dataobj.h"

#include "RWLock.h"
#include "DirectoryWatcher.h"
#include "DirectoryCache.h"
#include "ItemInfo.h"
#include "Utils.h"
#include "MainFrame.h"
#include "FileOperation.h"
#include "MainFrameImpl.h"
#include "SyncQueue.h"
#include "BackgroundIconLoader.h"
#include "Application.h"


IMPLEMENT_APP(App);

bool App::OnInit()
{
    directoryCache = new DirectoryCache;
    directoryCache->Initialize();
    backgroundIconLoader = new BackgroundIconLoader();
    backgroundIconLoader->Initialize();
    frame = new MainFrameImpl(NULL);
    backgroundIconLoader->RegisterFilePropertiesWatcher(frame->GetCompisiteFilePanel(0)->GetMainListView());
    backgroundIconLoader->RegisterFilePropertiesWatcher(frame->GetCompisiteFilePanel(1)->GetMainListView());
    frame->GetCompisiteFilePanel(0)->GetMainListView()->ChangePath("c:\\");
    frame->GetCompisiteFilePanel(1)->GetMainListView()->ChangePath("c:\\");
    frame->SetIcon(wxICON(IDI_APPLICATION_ICON));
    frame->Show(true);
    fileOperationManager = new FileOperationManager();
    fileOperationManager->RegisterWorkWatcher(frame);

    return true;
}
int App::OnExit()
{
    directoryCache->End();
    directoryCache->Delete();
    backgroundIconLoader->End();
    backgroundIconLoader->Delete();
    delete fileOperationManager;
    return 0;
}
DirectoryCache *App::GetDirectoryCache()
{
    return directoryCache;
}
BackgroundIconLoader *App::GetBackgroundIconLoader()
{
    return backgroundIconLoader;
}
FileOperationManager *App::GetFileOperationManager()
{
    return fileOperationManager;
}
MainFrameImpl *App::GetMainFrame()
{
    return frame;
}